const path = require('path');
const webpack = require('webpack');
const HtmlPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: ['vue-loader']
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.css', '.vue'], // 导入时省略后缀
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    }
  },
  plugins: [
      new webpack.BannerPlugin('最终版权归miranda所有'),
      // npm install html-webpack-plugin@3.2.0 --save-dev
      new HtmlPlugin({
        template: 'index.html'
      }),
      // npm install uglifyjs-webpack-plugin@1.1.1 --save-dev
      new UglifyJsPlugin()
  ]
};